how to convert a regular expression into a finite automaton